<!-- 上拉加载、 下拉刷新 -->
<template>
  <van-pull-refresh v-model="refreshing" @refresh="onRefresh">
    <van-list
      v-model="loading"
      :finished="false"
      finished-text="没有更多了"
      @load="onLoad"
    >
      <slot></slot>
    </van-list>
  </van-pull-refresh>
</template>
<script>
import { PullRefresh, List } from 'vant'
export default {
  props: {
    refreshing: {
      type: Boolean,
      default: false
    },
    listLoading: {
      type: Boolean,
      default: false
    }
  },
  data () {
    return {
      loading: true
    }
  },
  components: {
    [PullRefresh.name]: PullRefresh,
    [List.name]: List
  },
  watch: {
    listLoading (newVal) {
      console.log('listLoad', newVal)
      this.loading = newVal
    }
  },
  methods: {
    onRefresh () {
      this.$emit('refresh')
    },
    onLoad () {
      this.$emit('load')
    }
  }
}
</script>
